Skip to content

NP-790: Fix bundle not working in Github action#3

Merged
illiaizotov-dev merged 2 commits intomasterfrom
illia/NP-790
Apr 23, 2026
Merged

NP-790: Fix bundle not working in Github action#3
illiaizotov-dev merged 2 commits intomasterfrom
illia/NP-790

Conversation

@illiaizotov-dev
Copy link
Copy Markdown
Member

Github uses only lib/ folder, meaning the whole bundle must be available in Git as node_modules are ignored

Runtime and CI:
- action.yml now uses runs.using: node24 (was node16)
- Add .nvmrc pinning Node 24 and engines.node >= 24.0.0 in package.json
- Project is native ESM: package.json "type": "module", tsconfig.json
  module/moduleResolution: NodeNext, so every relative import in
  src/**/*.ts and tests/**/*.ts carries a .js extension per spec
- Compiled lib/*.js is native ESM; GitHub's node24 runtime loads it
  directly via Node's own ESM loader
- Add a project-level .npmrc pinning registry=https://registry.npmjs.org/
  so CI does not inherit a developer's private-registry config
- .github/workflows/test.yml bumps actions/checkout and actions/setup-node
  to v6 and runs lint + check + test + build

Dependency upgrades (aggressive majors, zero known vulnerabilities):
- @actions/core       1.x -> 3.0.1  (pure ESM)
- @actions/exec       1.x -> 3.0.0  (pure ESM)
- @actions/github     4.x -> 9.1.1  (fixes the broken @octokit/core/dist-types/types
                                     deep import from 8.0.1 + reaches @octokit/core@7,
                                     plugin-paginate-rest@14, plugin-rest-endpoint-methods@17,
                                     request@10, request-error@7, undici@6)
- @semantic-release/commit-analyzer       8 -> 13  (pure ESM)
- @semantic-release/release-notes-generator 9 -> 14 (pure ESM)
- conventional-changelog-conventionalcommits 4 -> 9 (pure ESM)
- typescript 4.4 -> 5.9, @types/node 16 -> 24, prettier 2 -> 3
- New: eslint 9 (flat config), typescript-eslint 8 (strict + stylistic),
       @eslint/js, globals

Source changes:
- src/github.ts: migrated to octokit.rest.{repos,git}.*
- Deleted src/ts.ts; replaced the custom Await<T> helper with the
  built-in TypeScript Awaited<T>
- src/action.ts: added VALID_RELEASE_TYPES set + isReleaseType type
  guard replacing the prior `as ReleaseType` cast; release_type output
  is only set after inc() succeeds
- src/main.ts: catch (error: unknown) with narrowing that surfaces
  error.stack and surfaces one level of error.cause (Error stack/message
  inline, non-Error causes JSON-stringified with a toString fallback)
- src/utils.ts: dropped the @ts-ignore on default-release-types by
  inlining the constant list (the internal module is not a public
  export), added explicit MappedReleaseRule return type, refactored
  for noUncheckedIndexedAccess
- types/semantic.d.ts: tightened `any` -> structural shapes

Tooling:
- tsconfig.json: target ES2023, strict + noUncheckedIndexedAccess +
  useUnknownInCatchVariables, module/moduleResolution NodeNext
- tsconfig.eslint.json drives type-aware ESLint across
  src/**, tests/**, types/**, *.mjs, and vitest.config.ts
- eslint.config.mjs (flat config) with strictTypeChecked +
  stylisticTypeChecked, plus a relaxed override for tests/**/*.ts that
  still enforces no-unused-vars with the ^_ escape hatch
- Prettier 3 is happy across the tree; .prettierignore keeps LICENSE,
  .nvmrc, and binary assets out of the formatter

Testing (Vitest 4):
- Replaced Jest 30 + ts-jest + @types/jest + @jest/globals with
  vitest@^4.1.5 as the single dev dependency for the test stack;
  dropped jest.config.mjs, tsconfig.test.json, and the local
  tests/__mocks__/@semantic-release/* stubs entirely because Vitest
  loads the real ESM packages natively
- Scripts: "test": "vitest run", "test:watch": "vitest"
- New vitest.config.ts is ~20 lines: node environment, clearMocks +
  restoreMocks, 10s timeout, no globals
- tests/github.test.ts: vi.mock('@actions/github', factory) hoisted
  above static imports; no more dynamic imports or awaited factories
- tests/action.test.ts + tests/utils.test.ts:
  * vi.mock('@actions/core', async importOriginal => { ...actual,
    debug: vi.fn(), info: vi.fn(), setOutput: vi.fn(), setFailed: vi.fn() })
    because Node seals the real ESM namespace and vi.spyOn cannot
    mutate it in place
  * vi.mock('../src/utils.js') and vi.mock('../src/github.js') with
    the same pattern; per-test behaviour goes through
    vi.mocked(utils.getCommits).mockImplementation(...) because ESM
    named imports are live bindings and spyOn on a namespace cannot
    redirect them
  * tests/action.test.ts installs the console.info suppression in
    beforeEach (restoreMocks: true restores any module-scope spy
    after the first test completes)
- Built-in Node imports use the node: specifier (node:fs, node:path)

Docs and metadata:
- README.md "Usage" example points at the StackAdapt fork and the
  v7.0.0 tag that this commit is publishing
- README.md "Developing locally" section documents the Vitest /
  ESLint / Prettier / tsc workflow
- README.md `release_branches` and `previous_tag` / `previous_version`
  output descriptions now match the actual `src/action.ts` behaviour
  (skip-tag-creation path, synthetic `{tag_prefix}0.0.0` default)
- action.yml inline descriptions for `release_branches`,
  `pre_release_branches`, and `previous_tag` brought into alignment
  with README + code; declares `previous_version` output explicitly
- package.json `repository.url` now points at the StackAdapt fork

Build output:
- .gitignore no longer excludes lib/; the checked-in build is native
  ESM targeting Node 24

Validation:
- 34/34 tests pass under Vitest (~0.6s)
- npm run lint clean (ESLint strict + stylistic)
- npm run check clean (Prettier 3)
- npm run build clean (tsc -> native ESM in lib/)
- npm audit: 0 vulnerabilities

Made-with: Cursor
@illiaizotov-dev illiaizotov-dev force-pushed the illia/NP-790 branch 2 times, most recently from 5a687a1 to f4f79e7 Compare April 23, 2026 16:38
@illiaizotov-dev illiaizotov-dev merged commit 1381244 into master Apr 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant